<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<el-button type="primary" icon="sc-icon-download" @click="onBatchExport">导出</el-button>
				<div class="right-panel-search" style="margin-left: 10px;">
					<el-select style="width: 100px;" v-model="search.status" clearable placeholder="状态" filterable>
						<el-option v-for="(item, key) in statuss" :key="key" :label="item" :value="key" />
					</el-select>
					<el-date-picker style="width: 150px;" v-model="search.start_time" value-format="X" type="date"
						placeholder="开始时间" />
					<el-date-picker style="width: 150px;" v-model="search.end_time" value-format="X" type="date"
						placeholder="截止时间" />
					<el-input style="width: 200px;" v-model="search.ordernum" placeholder="订单号" clearable></el-input>
					<el-input style="width: 100px;" v-model="search.member_id" placeholder="会员ID" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
			<div class="right-panel">
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="list.apiObj" row-key="id" stripe>
				<el-table-column label="ID" prop="id" width="100"></el-table-column>
				<el-table-column label="会员ID" prop="member_id" width="100"></el-table-column>
				<el-table-column label="订单号" prop="ordernum" width="180"></el-table-column>
				<el-table-column label="付款流水" prop="out_trade_no" width="180"></el-table-column>
				<el-table-column label="第三方单号" prop="tordernum" width="230"></el-table-column>
				<el-table-column label="金额" prop="amount" width="100"></el-table-column>
				<el-table-column label="类型" prop="type" width="100">
					<template #default="scope">
						<p>{{types[scope.row.type]}}</p>
					</template>
				</el-table-column>
				<el-table-column label="付款方式" prop="pay_type" width="80">
					<template #default="scope">
						<p>{{pay_types[scope.row.pay_type]}}</p>
					</template>
				</el-table-column>
				<el-table-column label="状态" prop="status" width="80">
					<template #default="scope">
						<p>{{statuss[scope.row.status]}}</p>
					</template>
				</el-table-column>
				<el-table-column label="创建时间" prop="create_time" width="150"></el-table-column>
			</scTable>
		</el-main>
	</el-container>


</template>

<script>
	import config from "@/config/table";
	export default {
		name: 'configureList',
		components: {},
		data() {
			return {
				search: {
					status: '',
					start_time: '',
					end_time: '',
					ordernum: '',
					member_id: ''
				},
				statuss: {
					'0': '未支付',
					'1': '已支付',
					'2': '付款失败'
				},
				pay_types: {
					'0': '未知',
					'1': '支付宝',
					'2': '微信',
					'3': '银联',
					'4': '抖音'
				},
				types: {
					'1': '快递订单',
					'2': '快递补差价',
					'3': '退款'
				},
				list: {
					apiObj: this.$API.fund.unionpay.list
				},
			}
		},
		mounted() {

		},
		methods: {
			async onBatchExport() {
				var reqData = {
					[config.request.page]: this.$refs.table.currentPage,
					[config.request.pageSize]: this.$refs.table.scPageSize,
					[config.request.prop]: this.$refs.table.prop,
					[config.request.order]: this.$refs.table.order
				}
				let search = JSON.parse(JSON.stringify(this.search))
				var res = await this.$API.fund.unionpay.list.get({
					...reqData,
					...this.$refs.table.tableParams,
					...search,
					is_export: 1
				});
				if (res.code == 200) {
					window.open(res.data.url, '_blank')
				} else {
					this.$alert(res.msg, "提示", {
						type: 'error'
					})
				}
			},
			//搜索
			upsearch() {
				// console.log(112, this.search)
				let search = JSON.parse(JSON.stringify(this.search))
				this.$refs.table.upData({
					...search
				})
			},

			//本地更新数据
			handleSaveSuccess(data, mode) {
				//为了减少网络请求，直接变更表格内存数据
				if (mode == 'add') {
					this.$refs.table.unshiftRow(data)
				} else if (mode == 'edit') {
					this.$refs.table.updateKey(data)
				}

				//当然也可以暴力的直接刷新表格
				// this.$refs.table.refresh()
			}
		}
	}
</script>

<style>
</style>
